<?php

class Core_Backend_Component_Ebook_View_Material_Create extends Core_Backend_Share_View_Form {
	
	protected function initialize(){
		parent::initialize();
		$this->setTemplatePath('edit');		
	}

    protected function buildToolbar($toolbar) {
    	$group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('ebook/material/index'), $this->__('share.button.back'));
        if($this->getIdentity()->isAllowAction('ebook_material_edit')){
	        $group = $toolbar->createGroup('save');
	        $group->addButton($this->__('share.button.save'))
	        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(NULL, 'save')."')");
        }
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('material_form')
                ->addHiddenField('id', 'material[id]');
        $form->addTextboxField($this->__('share.label.title'), 'title', 'material[title]', TRUE)->addRequiredRule();
        $form->addIndustryField($this->__('foundation.label.industry'),'industry_id','material[industry_id]',TRUE)->addRequiredRule();
        $form->addRoadField($this->__('foundation.label.road'),'road_id','material[road_id]',TRUE)->addRequiredRule();
        $form->addTextboxField($this->__('share.label.page_size'), 'poi_page_size', 'material[poi_page_size]',TRUE)
                ->addRequiredRule()
                ->addDigitsRule();
        $form->addPoiBrowserField($this->__('media.label.select_option'), 'poi_ids', 'material[poi_ids][]')
                ->setConfigFunction('configPoiBrowser');
        $form->createTab('base_option', $this->__('share.label.base_option'), array('field_title',
            'field_industry_id', 'field_road_id', 'field_poi_page_size'));
        $form->createTab('poi_option', $this->__('media.label.poi_option'), array('field_poi_ids'));
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}